//alert('这是addFile js弹出的对话框');

function selectall() {
    //alert('这是selectall弹出的对话框');
    selectallObj=document.getElementById('selectall');
    items=document.getElementsByClassName('item');
    //console.log(selectallObj.checked)
    for(i in items){
        items[i].checked=selectallObj.checked
    }
}

function batch_delete_project() {
    //console.log('123')
    ids=''
    $('input.item:checked').parent().next().each(function (index,elem) {
        if(index==$('input.item:checked').length-1){
            ids+=$(elem).text().replace(/\s+/g,'')
        }else{
            ids+=$(elem).text().replace(/\s+/g,'')+','
        }
    });
    console.log(ids)
    $.ajax({
        type:"post",
        url:"/index.php?r=home/batchdeleteproject",
        data:{ids:ids},
        success:function (response,status,xhr) {
            //console.log(response);
            parent.window.open('/index.php?r=home/project', '_top')
        },
        timeout:100000000, //如果超时10秒，就结束
        // error:function (xhr,errorText,errorType) { //错误后的行为
        //     console.log("errorText:"+errorText); //error
        //     console.log("errorType:"+errorType); //not found
        //     console.log("xhr.status:"+xhr.status); //404
        //     console.log("xhr.statusText:"+xhr.statusText); //not found
        // }
    });
}

function delete_project() {
    ids=arguments[1]
    $.ajax({
        type:"post",
        url:"/index.php?r=home/batchdeleteproject",
        data:{ids:ids},
        success:function (response,status,xhr) {
            //console.log(response);
            if(response.search("完成") != -1){
                parent.window.open('/index.php?r=home/project', '_top')
            }else{
                console.log(response)
            }
        },
        timeout:1000000, //如果超时1000毫秒，就结束
        // error:function (xhr,errorText,errorType) { //错误后的行为
        //     console.log("errorText:"+errorText); //error
        //     console.log("errorType:"+errorType); //not found
        //     console.log("xhr.status:"+xhr.status); //404
        //     console.log("xhr.statusText:"+xhr.statusText); //not found
        // }
    });
}

function edit_one() {
    ids=arguments[1]
    $.ajax({
        type:"post",
        url:"/index.php?r=home/editoneupload",
        data:{ids:ids},
        success:function (response,status,xhr) {
            console.log(response);
            //parent.window.open('/index.php?r=home/index', '_top')
        },
        timeout:10000000, //如果超时1000毫秒，就结束
        // error:function (xhr,errorText,errorType) { //错误后的行为
        //     console.log("errorText:"+errorText); //error
        //     console.log("errorType:"+errorType); //not found
        //     console.log("xhr.status:"+xhr.status); //404
        //     console.log("xhr.statusText:"+xhr.statusText); //not found
        // }
    });
}

function delete_download() {
    id=arguments[1]
    $.ajax({
        type:"post",
        url:"/index.php?r=home/deletedownload",
        data:{id:id},
        success:function (response,status,xhr) {
            //console.log(response);
            if(response.search('success')){
                parent.window.open('/index.php?r=home/download', '_top')
            }else{
                console.log(response)
            }
        },
        timeout:1000000000, //如果超时1000毫秒，就结束
        // error:function (xhr,errorText,errorType) { //错误后的行为
        //     console.log("errorText:"+errorText); //error
        //     console.log("errorType:"+errorType); //not found
        //     console.log("xhr.status:"+xhr.status); //404
        //     console.log("xhr.statusText:"+xhr.statusText); //not found
        // }
    });
}









